package com.weareint.autoconfig;

import com.weareint.feigncopy.AbsCacheMappingFeignDataService;
import com.weareint.feigncopy.AbsRedisCacheMappingFeignDataService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 *
 *
 * <pre>
 *
 * </pre>
 *
 * @author johnny
 * @date 2021-08-22 1:39 上午
 */
@Component
@ConditionalOnClass(StringRedisTemplate.class)
public class FeignMappingInitAutoConfig implements InitializingBean {

    private final StringRedisTemplate stringRedisTemplate;

    @Value("${spring.application.name}")
    private String appName;

    public FeignMappingInitAutoConfig(StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        AbsCacheMappingFeignDataService.appNamePrefix = appName;
        AbsRedisCacheMappingFeignDataService.stringRedisTemplate = stringRedisTemplate;
    }
}
